<?php
// +----------------------------------------------------------------------
// | 后台用户管理
// +----------------------------------------------------------------------
namespace app\common\model;
use think\Model;

class UserRechargeRule extends Model
{
	use \base\model\ModelTrait;

	 /**
     * 获取有效规则列表
     * @param $uid
     * @return float
     */
    public static function getValidList()
    {
    	$shop_id = request()->userInfo['shop_id'];
		return self::where('status',0)->where("shop_id",$shop_id)->where(function ($query) {
			$query->where(function ($query)  {
				$query->whereNull('expire_time');
			});
			$query->whereor(function ($query)  {
				$query->whereNotNull('expire_time');
				$query->where([['','exp',\Db::raw("date_format(now(),'%Y-%m-%d %H:%i:%s') < expire_time")]]);
			});
		})->select();
    }
	
	
		
}
